package msg_center

import (
	"net/http"
	"sync"
	"time"
)

type Client struct {
	// 应用编码
	appCode string
	// 应用秘钥
	appSecret string
	// 消息中心域名
	host string
	// 锁和http
	mu     sync.Mutex
	Client *http.Client
	// token
	accessTokenLock sync.Mutex
	accessToken     string
	tokenTime       time.Time
}

type MsgClientConfig struct {
	// 应用编码
	AppCode string
	// 应用秘钥
	AppSecret string
	// 消息中心域名
	Host string
}

type MsgContent struct {
	ReceiverIds []string `json:"receiver_ids"`
	Content     string   `json:"content"`
	TryTimes    int      `json:"try_times"`
	ConfirmUrl  string   `json:"confirm_url"`
	CallbackUrl string   `json:"callback_url"`
}

type MsgBody struct {
	AccessToken   string      `json:"access-token"`
	PushOrderCode string      `json:"push_order_code"`
	DelayTime     string      `json:"delay_time"` //时间格式为2020-11-11 12:12:13
	Wx            *MsgContent `json:"wx"`
	Sms           *MsgContent `json:"sms"`
	Site          *MsgContent `json:"site"`
	Email         *MsgContent `json:"email"`
}

type msgClientParams struct {
	AppCode   interface{} `json:"app_code"`
	AppSecret interface{} `json:"app_secret"`
}
